<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.4"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>miniFOC: hardware/uart.h File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectlogo"><img alt="Logo" src="Acme_LOGO.png"/></td>
  <td id="projectalign">
   <div id="projectname">miniFOC<span id="projectnumber">&#160;1.0.3</span>
   </div>
   <div id="projectbrief">This open-source project aims to accomplish a FOC(Field Oriented Control) scheme that is operatable with minimum costs in China.</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.4 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search",'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_42e555215cde261dd5295a864caa3e52.html">hardware</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#define-members">Macros</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle"><div class="title">uart.h File Reference</div></div>
</div><!--header-->
<div class="contents">

<p>this is the header file of <a class="el" href="uart_8c.html" title="this file contains the code implementation of UART interface initialization function and medium capac...">uart.c</a>.  
<a href="#details">More...</a></p>

<p><a href="uart_8h_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="define-members" name="define-members"></a>
Macros</h2></td></tr>
<tr class="memitem:ad0829c8bd2841fd6525781b3dbf496b7"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="uart_8h.html#ad0829c8bd2841fd6525781b3dbf496b7">uart_sendbyte</a>(x)</td></tr>
<tr class="memdesc:ad0829c8bd2841fd6525781b3dbf496b7"><td class="mdescLeft">&#160;</td><td class="mdescRight">UART send single byte macro.  <a href="uart_8h.html#ad0829c8bd2841fd6525781b3dbf496b7">More...</a><br /></td></tr>
<tr class="separator:ad0829c8bd2841fd6525781b3dbf496b7"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:afb2565a333438fc66b5725bf1e41ca0f"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="uart_8h.html#afb2565a333438fc66b5725bf1e41ca0f">uart_config</a> (void)</td></tr>
<tr class="memdesc:afb2565a333438fc66b5725bf1e41ca0f"><td class="mdescLeft">&#160;</td><td class="mdescRight">configure uart0 periph and its gpios  <a href="uart_8h.html#afb2565a333438fc66b5725bf1e41ca0f">More...</a><br /></td></tr>
<tr class="separator:afb2565a333438fc66b5725bf1e41ca0f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab01834c3618e9e1078f1b7e9512337c6"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="uart_8h.html#ab01834c3618e9e1078f1b7e9512337c6">mdtp_data_transmit</a> (unsigned char pid, const unsigned char *buffer)</td></tr>
<tr class="memdesc:ab01834c3618e9e1078f1b7e9512337c6"><td class="mdescLeft">&#160;</td><td class="mdescRight">medium capacity data transmission protocol packing function  <a href="uart_8h.html#ab01834c3618e9e1078f1b7e9512337c6">More...</a><br /></td></tr>
<tr class="separator:ab01834c3618e9e1078f1b7e9512337c6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a8b1fe807c1672229711abeb195185046"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="uart_8h.html#a8b1fe807c1672229711abeb195185046">mdtp_receive_handler</a> (unsigned char data)</td></tr>
<tr class="memdesc:a8b1fe807c1672229711abeb195185046"><td class="mdescLeft">&#160;</td><td class="mdescRight">medium capacity data transmission protocol unpacking handler  <a href="uart_8h.html#a8b1fe807c1672229711abeb195185046">More...</a><br /></td></tr>
<tr class="separator:a8b1fe807c1672229711abeb195185046"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6d278b36110f5f0e56b59e058b867b65"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="uart_8h.html#a6d278b36110f5f0e56b59e058b867b65">mdtp_callback_handler</a> (unsigned char pid, const unsigned char *data)</td></tr>
<tr class="memdesc:a6d278b36110f5f0e56b59e058b867b65"><td class="mdescLeft">&#160;</td><td class="mdescRight">user callback function for unpacking completion of medium capacity transport protocol  <a href="uart_8h.html#a6d278b36110f5f0e56b59e058b867b65">More...</a><br /></td></tr>
<tr class="separator:a6d278b36110f5f0e56b59e058b867b65"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p >this is the header file of <a class="el" href="uart_8c.html" title="this file contains the code implementation of UART interface initialization function and medium capac...">uart.c</a>. </p>
<dl class="section author"><dt>Author</dt><dd>Lao·Zhu </dd></dl>
<dl class="section version"><dt>Version</dt><dd>V1.0.1 </dd></dl>
<dl class="section date"><dt>Date</dt><dd>10. October 2021 </dd></dl>

<p class="definition">Definition in file <a class="el" href="uart_8h_source.html">uart.h</a>.</p>
</div><h2 class="groupheader">Macro Definition Documentation</h2>
<a id="ad0829c8bd2841fd6525781b3dbf496b7" name="ad0829c8bd2841fd6525781b3dbf496b7"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ad0829c8bd2841fd6525781b3dbf496b7">&#9670;&nbsp;</a></span>uart_sendbyte</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define uart_sendbyte</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">x</td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<b>Value:</b><div class="fragment"><div class="line">                            ;   usart_data_transmit(USART0, (uint8_t) x);\</div>
<div class="line">                            while (RESET ==usart_flag_get(USART0, USART_FLAG_TBE))</div>
</div><!-- fragment -->
<p>UART send single byte macro. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">x</td><td>byte to be send from UART </td></tr>
  </table>
  </dd>
</dl>

<p class="definition">Definition at line <a class="el" href="uart_8h_source.html#l00016">16</a> of file <a class="el" href="uart_8h_source.html">uart.h</a>.</p>

</div>
</div>
<h2 class="groupheader">Function Documentation</h2>
<a id="a6d278b36110f5f0e56b59e058b867b65" name="a6d278b36110f5f0e56b59e058b867b65"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a6d278b36110f5f0e56b59e058b867b65">&#9670;&nbsp;</a></span>mdtp_callback_handler()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void mdtp_callback_handler </td>
          <td>(</td>
          <td class="paramtype">unsigned char&#160;</td>
          <td class="paramname"><em>pid</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const unsigned char *&#160;</td>
          <td class="paramname"><em>data</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>user callback function for unpacking completion of medium capacity transport protocol </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">pid</td><td>medium capacity transport protocol package id </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">data</td><td>received data array of size 8 bytes </td></tr>
  </table>
  </dd>
</dl>

<p class="definition">Definition at line <a class="el" href="main_8c_source.html#l00028">28</a> of file <a class="el" href="main_8c_source.html">main.c</a>.</p>

<p class="reference">References <a class="el" href="pid_8h_source.html#l00018">ANGLE_LOOP_CONTROL</a>, <a class="el" href="pid_8c_source.html#l00028">angle_pid_handler</a>, <a class="el" href="pid_8h_source.html#l00029">PID_Structure_t::expect</a>, <a class="el" href="foc_8c_source.html#l00028">foc_parameter_available_flag</a>, <a class="el" href="foc_8c_source.html#l00020">FOC_Struct</a>, <a class="el" href="system_8c_source.html#l00070">int32_to_float()</a>, <a class="el" href="pid_8h_source.html#l00027">PID_Structure_t::kd</a>, <a class="el" href="pid_8h_source.html#l00026">PID_Structure_t::ki</a>, <a class="el" href="pid_8h_source.html#l00025">PID_Structure_t::kp</a>, <a class="el" href="main_8c_source.html#l00021">minifoc_fsm_state</a>, <a class="el" href="pid_8c_source.html#l00033">pid_config()</a>, <a class="el" href="pid_8c_source.html#l00020">pid_control_mode_flag</a>, <a class="el" href="pid_8c_source.html#l00016">pid_parameter_available_flag</a>, <a class="el" href="pid_8h_source.html#l00016">SPEED_LOOP_CONTROL</a>, <a class="el" href="pid_8c_source.html#l00024">speed_pid_handler</a>, <a class="el" href="pid_8h_source.html#l00032">PID_Structure_t::sum_maximum</a>, <a class="el" href="pid_8h_source.html#l00014">TORQUE_LOOP_CONTROL</a>, and <a class="el" href="foc_8h_source.html#l00020">FOC_Structure_t::user_expect</a>.</p>

<p class="reference">Referenced by <a class="el" href="uart_8c_source.html#l00036">mdtp_receive_handler()</a>.</p>

</div>
</div>
<a id="ab01834c3618e9e1078f1b7e9512337c6" name="ab01834c3618e9e1078f1b7e9512337c6"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ab01834c3618e9e1078f1b7e9512337c6">&#9670;&nbsp;</a></span>mdtp_data_transmit()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void mdtp_data_transmit </td>
          <td>(</td>
          <td class="paramtype">unsigned char&#160;</td>
          <td class="paramname"><em>pid</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const unsigned char *&#160;</td>
          <td class="paramname"><em>buffer</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>medium capacity data transmission protocol packing function </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">pid</td><td>medium capacity transport protocol package id </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">buffer</td><td>transmit data array of size 8 bytes </td></tr>
  </table>
  </dd>
</dl>

<p class="definition">Definition at line <a class="el" href="uart_8c_source.html#l00113">113</a> of file <a class="el" href="uart_8c_source.html">uart.c</a>.</p>

<p class="reference">References <a class="el" href="uart_8h_source.html#l00016">uart_sendbyte</a>.</p>

<p class="reference">Referenced by <a class="el" href="report_8c_source.html#l00069">report_angle_speed()</a>, and <a class="el" href="report_8c_source.html#l00015">report_local_variable()</a>.</p>

</div>
</div>
<a id="a8b1fe807c1672229711abeb195185046" name="a8b1fe807c1672229711abeb195185046"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a8b1fe807c1672229711abeb195185046">&#9670;&nbsp;</a></span>mdtp_receive_handler()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void mdtp_receive_handler </td>
          <td>(</td>
          <td class="paramtype">unsigned char&#160;</td>
          <td class="paramname"><em>data</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>medium capacity data transmission protocol unpacking handler </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">data</td><td>data received from UART peripheral </td></tr>
  </table>
  </dd>
</dl>

<p class="definition">Definition at line <a class="el" href="uart_8c_source.html#l00036">36</a> of file <a class="el" href="uart_8c_source.html">uart.c</a>.</p>

<p class="reference">References <a class="el" href="main_8c_source.html#l00028">mdtp_callback_handler()</a>, <a class="el" href="uart_8c_source.html#l00030">mdtp_receive_data_buffer</a>, <a class="el" href="uart_8c_source.html#l00026">mdtp_receive_number_counter</a>, <a class="el" href="uart_8c_source.html#l00022">mdtp_receive_status</a>, and <a class="el" href="system_8c_source.html#l00049">user_memset()</a>.</p>

<p class="reference">Referenced by <a class="el" href="gd32f1x0__it_8c_source.html#l00092">USART0_IRQHandler()</a>.</p>

</div>
</div>
<a id="afb2565a333438fc66b5725bf1e41ca0f" name="afb2565a333438fc66b5725bf1e41ca0f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#afb2565a333438fc66b5725bf1e41ca0f">&#9670;&nbsp;</a></span>uart_config()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void uart_config </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>configure uart0 periph and its gpios </p>

<p class="definition">Definition at line <a class="el" href="uart_8c_source.html#l00143">143</a> of file <a class="el" href="uart_8c_source.html">uart.c</a>.</p>

<p class="reference">References <a class="el" href="config_8h_source.html#l00024">UART_BAUDRATE</a>, and <a class="el" href="config_8h_source.html#l00037">UART_PRIORITY</a>.</p>

<p class="reference">Referenced by <a class="el" href="main_8c_source.html#l00139">main()</a>.</p>

</div>
</div>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.4
</small></address>
</body>
</html>
